package com.caiyi.financial.nirvana.sms;

import com.alibaba.fastjson.JSON;
import org.apache.commons.io.FileUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CmppStatus {

    public static void main(String[] args) throws Exception {
        List<String> list = FileUtils.readLines(new File("C:\\Users\\lvcha.000\\Desktop\\status.csv"), "utf-8");
        Jedis jedis = new Jedis("39.100.85.203", 8090);
        Pipeline line = jedis.pipelined();
        for (int i = 0; i < list.size(); i++) {
            String item = list.get(i);
            String[] strs = item.split(",");
            Map m = new HashMap();
            m.put("batchId", strs[0].replace("\"", "").replace(" ", ""));
            m.put("phone", strs[1].replace("\"", ""));
            m.put("status", Integer.parseInt(strs[2].replace("\"", "")));
            m.put("result", strs[3].replace("\"", ""));
            m.put("uid", strs[4].replace("\"", ""));
            m.put("account", strs[5].replace("\"", ""));
            m.put("receiveTime", strs[6].replace("\"", "").replace("/", "-"));
            String key = "sms:queue:cmpp:report:list:" + strs[5].replace("\"", "");
//            String key = "sms:queue:cmpp:report:list:100000";
            String value = JSON.toJSONString(m);
//            System.out.println(key + "=" + value);
            line.lpush(key, value);
        }
        int count = line.syncAndReturnAll().size();
        System.out.println("=========================list size is : " + list.size() + ", success : " + count);
        jedis.close();
    }

}
